@extends('home.layout.base')
@section('title', '购物车列表页')
@section('pluginstyle')
<script src="{{ asset('/dist/home/js/1102.js') }}"></script>
<link rel="stylesheet" href="{{ asset('/dist/home/css/search.css') }}" />
<link rel="stylesheet" href="dist/home/css/v3203b5.css">
<link rel="stylesheet" href="dist/home/css/qiku.css">
<link rel="stylesheet" href="dist/home/css/store.css">
<link rel="stylesheet" href="dist/home/css/qikoo_user.css">
<script>var _isindex = 0;</script>
@endsection
@section('content')
<div class="gCart">
    <div class="hd">
        <h3>我的购物车</h3>
    </div>
    <div class="bd">
        <div class="cartList">
            <div class="hd">
                <div class="col1">
                    商品信息
                </div>
                <div class="col2">
                    单价
                </div>
                <div class="col3">
                    数量
                </div>
                <div class="col4">
                    小计
                </div>
                <div class="col5">
                    操作
                </div>
            </div>
            <style>
                .wrap_row{border-bottom:1px dashed #eee}.icon_zp{background-color:#F95E38;color:#fff}.icon_zp,.icon_zp_no{border-radius:2px;display:inline-block;padding:2px 5px}.icon_zp_no{background-color:#ededed;color:#333}.zp_title{margin:6px 0 2px}.zp_chose{color:#c00;cursor:pointer}.zp_info{line-height:16px;overflow:hidden;padding-left:15px;text-align:left}.row_list{background-color:#F5F5F5}.wrap_zp{margin-bottom:15px;margin-top:-15px;position:relative}.zp_sanjiao{border:15px solid #fff;border-bottom:15px solid #F5F5F5;height:0;left:67px;position:absolute;width:0}.zp_space{height:30px}.dn{display:none}.wrap_row:last-child{border-bottom:0}.row_list .r3{font-size:16px}.cartList .bd .row{border-bottom:0}
            </style>
            <div class="bd">
                <div class="wrap_row">
                    <div class="row">
                        <?php $sum = 0 ?>
                        @foreach ($data as $tmp)
                        <?php $sum += $tmp->cart_price * $tmp->cart_num ?>
                        <div class="r1">
                            <img class="item-img" src="{{ asset($tmp->cart_img) }}">
                            <a class="item-namexx" href="{{ url('/item', [$tmp->goods_id]) }}" target="_blank"> {{$tmp->goods_name}}  </a>
                        </div>
                        <div class="r2">
                            <span class="goodsPrice">{{$tmp->cart_price}}</span>元
                        </div>
                        <div class="r3">
                            <div class="gcIpt">
                                <a href="javascirpt:void(0);" data-id="{{ $tmp->id }}" class="decrement"></a>
                                <input type="text" class="goodsCount" value="{{$tmp->cart_num}}">
                                <a href="javascirpt:void(0);" data-id="{{ $tmp->id }}" class="increment"></a>
                            </div>
                            <div class="errTip">
                                已达到最大购买数量
                            </div>
                        </div>
                        <div class="r4">
                            <span class="pc">{{$tmp->cart_price*$tmp->cart_num}}</span>元
                        </div>
                        <div class="r5">
                            <a href="{{url("/shopcar/delete", [$tmp->id])}}" class="delOrder">删除</a>
                        </div>
                        @endforeach
                    </div>
                </div>
            </div>
            <div class="gAmount">
                (商品总计)：<span>{{$sum}}</span>元
            </div>
            <div class="btn">
                <a href="{{url("/list")}}" class="b1" title="继续购物">继续购物</a>
                <a href="/order" class="b2" title="去结算">去结算</a>
            </div>
        </div>
    </div>
</div>
@endsection
@section('pluginscript')
<script src="{{ asset('/js/shopcar.js') }}"></script>
<script type="text/javascript">
$('.decrement').click(function(){
    var url = "{{ url('/shopcar/change') }}";
    var input = $(this).siblings('input');
    var data = {};
    data.id = $(this).attr('data-id');
    data.act = 'dec';
    MK.shopcart.changeNum(input, url, data, changeShow());
});
$('.increment').click(function(){
    var url = "{{ url('/shopcar/change') }}";
    var input = $(this).siblings('input');
    var data = {};
    data.id = $(this).attr('data-id');
    data.act = 'inc';
    MK.shopcart.changeNum(input, url, data, changeShow());
});

function changeShow(){
    var total = 0;
    $('.goodsPrice').each(function(i){
        var price = parseFloat($(this).text());
        var num = $('.goodsCount').eq(i).val();
        var thistotal = price * num;
        $('.pc').eq(i).text(thistotal);
        total += thistotal;
    });
    $('.gAmount span').text(total);
}
</script>
@endsection
